

require "data/ExperimentalData"
require "data/PhraseCards"

require "analysis/AvgDurationBtwCharactersAtPhrasesLevel"
require "analysis/AvgDurationBtwCharactersAtPhrasesLevel2" 
require "analysis/AvgErrorRate"
require "analysis/AvgErrorRate2"
require "analysis/SpellCheck"
require "analysis/SpellCheck2"
require "analysis/CorrelationAnalysis"


class Analyzer
  
  def initialize(experimentalData, phraseCards)
    @experimentalData = experimentalData
    @phraseCards = phraseCards  
  end
  

  def performAnalysis

    dir = "/Users/kklo/Desktop/543Results/bs_count_learning_curve"
    AvgErrorRate.new.analyze(dir, @experimentalData, @phraseCards)
    
    puts "1"

    dir = "/Users/kklo/Desktop/543Results/bs_count_avg"
    ar = AvgErrorRate2.new
    ar.analyze(dir, @experimentalData, @phraseCards)
    errs = ar.get_all_data    
    
    puts "2"
    
    dir = "/Users/kklo/Desktop/543Results/durvation_learning_curve"
    AvgDurationBtwCharactersAtPhrasesLevel.new.analyze(dir, @experimentalData, @phraseCards)
    
    puts "3"
    
    dir = "/Users/kklo/Desktop/543Results/durvation_avg"
    pa = AvgDurationBtwCharactersAtPhrasesLevel2.new
    pa.analyze(dir, @experimentalData, @phraseCards)
    performance = pa.get_all_data
    
    
    puts "4"
    
    dir = "/Users/kklo/Desktop/543Results/spelling_mistakes_learning_curve"
    SpellCheck.new.analyze(dir, @experimentalData, @phraseCards)
    
    puts "5"

    dir = "/Users/kklo/Desktop/543Results/spelling_mistakes_avg"
    sa = SpellCheck2.new
    sa.analyze(dir, @experimentalData, @phraseCards)
    accuracy = sa.get_all_data 
    
    
    puts "6"
    
    # Correlation analysis
    dir = "/Users/kklo/Desktop/543Results/correlations"
    cor = CorrelationAnalysis.new 
    cor.analysis(dir, "time","bscounts", performance, errs)
    
    puts "7"
    
    cor.analysis(dir, "time","typo", performance, accuracy)
    
    puts "8"
    
    cor.analysis(dir, "bscounts","typo", errs, accuracy)    
  end
  
end